using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms.Design;
using System.Windows.Forms;

namespace BardsTaleMapViewer {
  [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.ToolStrip)]
  public class ToolStripNumericUpDown : ToolStripControlHost {
    public ToolStripNumericUpDown ()
      : base (new NumericUpDown ()) {
    }

    protected override void OnSubscribeControlEvents (Control control) {
      base.OnSubscribeControlEvents (control);
      ((NumericUpDown) control).ValueChanged += new EventHandler (OnValueChanged);
    }

    protected override void OnUnsubscribeControlEvents (Control control) {
      base.OnUnsubscribeControlEvents (control);
      ((NumericUpDown) control).ValueChanged -= new EventHandler (OnValueChanged);
    }

    public event EventHandler ValueChanged;

    public NumericUpDown NumericUpDownControl {
      get {
        return Control as NumericUpDown;
      }
    }

    public Decimal Value {
      get {
        return (NumericUpDownControl.Value);
      }
      set {
        NumericUpDownControl.Value = value;
      }
    }

    public Decimal Maximum {
      get {
        return (NumericUpDownControl.Maximum);
      }
      set {
        NumericUpDownControl.Maximum = value;
      }
    }

    public Decimal Minimum {
      get {
        return (NumericUpDownControl.Minimum);
      }
      set {
        NumericUpDownControl.Minimum = value;
      }
    }

    public new HorizontalAlignment TextAlign {
      get {
        return (NumericUpDownControl.TextAlign);
      }
      set {
        NumericUpDownControl.TextAlign = value;
      }
    }

    public void OnValueChanged (object sender, EventArgs e) {
      if (ValueChanged != null) {
        ValueChanged (this, e);
      }
    }
  }
}
